$(document).ready(function(){

/********************** validation functions defination ********************/
$.fn.emailFormat = function() {
    var value= $(this).attr('value');
    var args = arguments[0] || {};
    var errorClass = args.errorClass;
    var emailRegex = /^([0-9a-zA-Z]([-\.\w]*[0-9a-zA-Z])*@([0-9a-zA-Z][-\w]*[0-9a-zA-Z]\.)+[a-zA-Z]{2,9})$/;
    if(!emailRegex.test(value)){
        $(errorClass).css('visibility', 'visible');
        return false;
    }
    else{
        $(errorClass).css('visibility', 'hidden');
        return true;
    }
}

$.fn.notEmpty = function() {
     var value= $(this).attr('value');
     var args = arguments[0] || {};
     var errorClass = args.errorClass;
	 // alert(errorClass);
     if(value.length == 0){
         $(errorClass).css('visibility', 'visible');
		 // alert('false');
         return false;
     }
     else{
         $(errorClass).css('visibility', 'hidden');
		 // alert('true');
         return true;
     }
 }

$.fn.isNumber = function() {
    var isNumReg = /^\d+$/;
    var value= $(this).attr('value');
    var args = arguments[0] || {};
    var errorClass = args.errorClass;
	 // alert(errorClass);
    if(!isNumReg.test(value)){
        $(errorClass).css('visibility', 'visible');
		 // alert('false');
        return false;
    }
    else{
        $(errorClass).css('visibility', 'hidden');
		 // alert('true');
        return true;
    }
}

$.fn.equal = function() {
    var value= $(this).attr('value');
    var args = arguments[0] || {};
    var errorClass = args.errorClass;
    var equalTo = args.equalTo;
    if(value != $(equalTo).attr('value') || value.length == 0){
        $(errorClass).css('visibility', 'visible');
        return false;
    }
    else{
        $(errorClass).css('visibility', 'hidden');
        return true;
    }
 }

 $.fn.complexPassword = function() {
     var value= $(this).attr('value');
     var uppercase = /[A-Z]/;
     var lowercase = /[a-z]/;
     var numbers = /\d/;
     var special = /[!@#$%^&*()?]/;
     var strn;
     if(value.length < 6 && value.length != 0){
         $('.short').css('display', 'block');
         $('.word').text('Short');
         $('.weak').css('display', 'none');
         $('.good').css('display', 'none');
         $('.strong').css('display', 'none');
         strn = "short";
     }
     if(value.length >= 6 && (uppercase.test(value) || lowercase.test(value) || numbers.test(value))){
         $('.weak').css('display', 'block');
         $('.word').text('Weak');
         $('.good').css('display', 'none');
         $('.strong').css('display', 'none');
         strn = "weak";
     }
     if(value.length >= 6 && lowercase.test(value) && numbers.test(value)){
         $('.good').css('display', 'block');
         $('.word').text('good');
         $('.strong').css('display', 'none');
         strn = "good";
     }
     if(value.length >= 6 && lowercase.test(value) && numbers.test(value) && uppercase.test(value)){
         $('.strong').css('display', 'block');
         $('.word').text('Strong');
         $('.very-strong').css('display', 'none');
         strn = "strong";
     }
     if(value.length >= 6 && uppercase.test(value)&&numbers.test(value) ){
         $('.strong').css('display', 'block');
         $('.word').text('Strong');
         $('.very-strong').css('display', 'none');
         strn = "strong";
     }
     if(value.length >= 6 && lowercase.test(value) && numbers.test(value) && uppercase.test(value) && special.test(value)){
        $('.very-strong').css('display', 'block');
         $('.word').text('Very Strong');
         strn = "veryStrong";
     }
    return strn;
 }

 $.fn.checkterms = function() {
		if($("#chbox").is(':checked')){
			
			$(".check-terms-error").css("visibility", "hidden");
			return true;
		}else{
		
			$(".check-terms-error").css("visibility",   "visible");
			return false;
		}
	}
});




